﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GeckoPhotos.Util.Extensions
{
    
    public static class DateTimeExtensions
    {

        public static string ToPrettyString(this DateTime dt)
        {
            TimeSpan ts = dt.Subtract(DateTime.Now);

            string dayPart;
            if(ts.Days > 7)
                dayPart = dt.ToShortDateString();
            else if(ts.Days > 3)
                dayPart = String.Format("next {0}", dt.DayOfWeek.ToString());
            else if (ts.Days > 0)
                dayPart = dt.DayOfWeek.ToString();
            else if (ts.Days == 1)
                dayPart = "tomorrow";
            else if (ts.Days == 0)
                dayPart = "today";
            else if (ts.Days == -1)
                dayPart = "yesterday";
            else if(ts.Days > -4)
                dayPart = dt.DayOfWeek.ToString();
            else
                dayPart = dt.ToShortDateString();

            // TODO: gussy this up in the same manner as dayPart
            string timePart = dt.ToShortTimeString();

            return String.Format("{0} {1}", dayPart, timePart);
        }

    }

}